home *** CD-ROM | disk | FTP | other *** search
- /*
- dshell v3
-
- 画面色調整
- */
-
- #include "dsh.h"
-
- static void rgb_select(int );
- static void disp_rgbbar(int , int , int );
- static void disp_rgb(int, int, ushort [3]);
-
-
- void
- Menu_rgb()
- {
- #define ITEMS 9 /* アイテムの数 */
- #define MAX_MESLEN 6 /* 一番長いメッセージのバイト数 */
-
- #define WIN_SX 29 /* ウィンドウ開位置X */
- #define WIN_SY (31 - ITEMS - 1) /* 同Y */
-
- static const uchar *mes[ITEMS] =
- {
- " テキスト3",
- " テキスト2",
- " テキスト1",
- "主背景",
- "上下帯",
- "メニュー地",
- "スケール地",
- " スケール ",
- " 終了 "
- };
-
- /*
- ! 枠の表示
- ! マウスエリアの設定
- */
- tbox_w2(WIN_SX, WIN_SY, WIN_SX + MAX_MESLEN, WIN_SY + ITEMS);
-
-
- /*
- ! アイテムの表示
- */
- B_COLOR(3);
- {
- int i;
-
- for (i = 0; i < ITEMS; i++) {
- B_LOCATE(WIN_SX, WIN_SY + i);
- B_PRINT(mes[i]);
- }
- }
-
- /*
- ! マウス離されるの待ち
- */
- wait_mb_off();
- /*
- ! アイテムセレクト
- */
- while (1) {
- int dmx, dmy, mx, my, omy = -1, mbl, mbr;
- int selected = -1;
-
- msarea(WIN_SX * 8, WIN_SY * 16, (WIN_SX + MAX_MESLEN) * 8, (WIN_SY + ITEMS) * 16);
- do {
- p_time(0);
- dmsstat(&dmx, &dmy, &mbl, &mbr);
- dmspos(&mx, &my);
- {
- int i;
-
- for (i = 0; i < ITEMS; i++) {
- if (my > (WIN_SY + i) * 16 && my < (WIN_SY + i + 1) * 16 && omy != i) {
- int j;
-
- for (j = 0; j < ITEMS; j++) {
- B_LOCATE(WIN_SX, WIN_SY + j);
- B_PRINT(mes[j]);
- }
- B_COLOR(13); /* 水色反転 */
- B_LOCATE(WIN_SX, WIN_SY + i);
- B_PRINT(mes[i]);
- B_COLOR(3);
- omy = i;
- selected = i;
- break;
- }
- }
- }
- } while (!(mbl || mbr));
-
- /*
- ! キャンセルか?
- */
- if (mbr == -1) {
- selected = -1;
- }
- /*
- ! 選択されていたら色設定へ
- */
- if (selected != -1 && selected != ITEMS - 1) {
- rgb_select(selected - 3);
- } else {
- /*
- ! 色設定を終了
- */
- break;
- }
- }
-
-
- /*
- ! ウィンドウを元に戻す
- */
- msarea(0, 0, GWIDTH - 1, 511);
- {
- int i;
-
- for (i = WIN_SY - 2; i <= 29; i++) {
- p_lin(lp + i, i);
- }
- }
-
- /*
- ! マウス離されるの待ち
- */
- wait_mb_off();
-
-
- #undef ITEMS
- #undef MAX_MESLEN
- #undef WIN_SX
- #undef WIN_SY
-
- }
-
-
- /*
- 指定されたパレットを変更する
- */
- static void
- rgb_select(int pal_no)
- {
- #define ITEMS 5
-
- static const uchar *scr[ITEMS] =
- {
- "R------------------------------- [00]",
- "G------------------------------- [00]",
- "B------------------------------- [00]",
- "",
- " 初期値 Code ?:XXXX 設定 中止"
- };
- int dmx, dmy, mx, my, mbl, mbr;
- ushort ocolor_code, color_code;
- ushort c[3];
- #define r (c[0])
- #define g (c[1])
- #define b (c[2])
-
- #define WIN_SX 36
- #define WIN_SY 24
-
-
- #define MAX_MESLEN 39
- tbox_w2(WIN_SX, WIN_SY, WIN_SX + MAX_MESLEN, WIN_SY + ITEMS);
- msarea(WIN_SX * 8, WIN_SY * 16, (WIN_SX + MAX_MESLEN) * 8, (WIN_SY + ITEMS) * 16);
-
-
- /*
- ! 初期画面設定
- */
- {
- int i;
-
- for (i = 0; i < ITEMS; i++) {
- B_LOCATE(WIN_SX, WIN_SY + i);
- B_PRINT(scr[i]);
- }
- B_LOCATE(WIN_SX + 2, WIN_SY + ITEMS - 1);
- B_COLOR(6);
- B_PRINT((uchar *) "初期化");
- B_COLOR(3);
- }
-
- /*
- ! 現在値の表示
- */
- color_code = ocolor_code = dpalet(pal_no, -1);
- disp_rgb(pal_no, color_code, c);
-
- wait_mb_off();
-
- /*
- ! 設定開始
- */
- {
-
- while (1) {
- p_time(0);
- dmsstat(&dmx, &dmy, &mbl, &mbr);
- dmspos(&mx, &my);
-
- if (mbr == -1) { /* 右ボタンでキャンセルしたか? */
- dpalet(pal_no, ocolor_code);
- break;
- }
- if (mbl == -1) { /* 左ボタンをクリックしたか? */
- int i;
-
- /*
- ! レベルメータのアクセスチェック
- */
- for (i = 0; i < 3; i++) {
- if (my > (WIN_SY + i) * 16 && my < (WIN_SY + i + 1) * 16) { /* i行目に入っているか? */
- if (mx > (WIN_SX + 2 - 2) * 8 && mx < (WIN_SX + 2 + 31) * 8) { /* レベルメータの上か? */
- int x;
- char buf[96];
-
- x = (mx - (WIN_SX + 2) * 8); /* オフセットピクセルに換算 */
- x = (x >= 0) ? x / 8 + 1 : 0; /* メータの0テキスト座標判定 */
- disp_rgbbar(WIN_SX + 2, WIN_SY + i, x); /* レベルの表示 */
- c[i] = x;
- color_code = (r << 6 | g << 11 | b << 1);
- dpalet(pal_no, color_code);
- B_LOCATE(WIN_SX + 20, WIN_SY + ITEMS - 1);
- sprintf(buf, "%1d:%04X", pal_no, color_code);
- B_PRINT(buf);
- }
- }
- }
-
- /*
- ! 決定又は中止
- */
- if (my > (WIN_SY + ITEMS - 1) * 16 && my < (WIN_SY + ITEMS) * 16) { /* 項目行に入っているか? */
- if (mx > (WIN_SX + 28) * 8 && mx < (WIN_SX + 28 + 4) * 8) { /* 設定 */
- if (pal_no < 0)
- tx_col[-pal_no] = color_code;
- else
- gr_col[pal_no] = color_code;
- break;
- }
- if (mx > (WIN_SX + 34) * 8 && mx < (WIN_SX + 34 + 4) * 8) { /* 中止 */
- dpalet(pal_no, ocolor_code);
- break;
- }
- if (mx > (WIN_SX + 2) * 8 && mx < (WIN_SX + 2 + 6) * 8) { /* 初期値 */
- if (pal_no < 0)
- color_code = otx_col[-pal_no];
- else
- color_code = ogr_col[pal_no];
- dpalet(pal_no, color_code);
- disp_rgb(pal_no, color_code, c);
- /* break; しない */
- }
- }
- }
- }
- }
-
-
- /* getch(); */
-
- /*
- ! 画面初期化
- */
- {
- int i;
-
- for (i = 0; i < ITEMS; i++) {
- B_LOCATE(WIN_SX, WIN_SY + i);
- B_PRINT(scr[i]);
- }
- }
- wait_mb_off();
-
- }
-
- /*
- RGBの成分を棒で表わす
-
- pos=0~2
- len=0~31
- */
- static void
- disp_rgbbar(int pos_x, int pos_y, int len)
- {
- char on = '>', /* レベルメータの種類 */
- off = '-';
- char buf[96];
-
- B_LOCATE(pos_x, pos_y);
- {
- int i;
-
- for (i = 0; i < len; i++) {
- B_PUTC(on);
- }
- for (i = len; i < 31; i++) {
- B_PUTC(off);
- }
- B_RIGHT(2);
- sprintf(buf, "%02d", len);
- B_PRINT(buf);
- }
- }
-
-
- static void
- disp_rgb(int pal_no, int color_code, ushort c[3])
- {
- char buf[96];
- int i, y;
-
- r = (color_code & 0x07c0) >> 6;
- g = (color_code & 0xf800) >> 11;
- b = (color_code & 0x003e) >> 1;
-
- y = WIN_SY;
- for (i = 0; i < 3; i++)
- disp_rgbbar(WIN_SX + 2, y++, c[i]);
-
- B_LOCATE(WIN_SX + 19, WIN_SY + ITEMS - 1);
- sprintf(buf, "%2d:%04X", pal_no, color_code);
- B_PRINT(buf);
- }
- #undef r
- #undef g
- #undef b
-
- /* [ EOF ] */
-